import numpy as np
import warnings
warnings.filterwarnings('ignore')
import tensorflow as tf
from tensorflow.keras import layers,optimizers,Sequential,losses
from tensorflow.keras.layers import Dense,Dropout
from sklearn.metrics import classification_report,accuracy_score,confusion_matrix
from sklearn.model_selection import train_test_split

data = np.loadtxt(r'../data-03-diabetes.csv',delimiter=',')
x = data[:,:-1]
y = data[:,-1:]

train_x,test_x,train_y,test_y = train_test_split(x,y,test_size=0.3)

model  = Sequential([
    Dense(8,activation='relu'),
    Dense(1,activation='sigmoid'),
])

model.compile(
    optimizer=optimizers.Adam(),
    loss=losses.BinaryCrossentropy(),
    metrics=['accuracy']
)

model.fit(train_x,train_y,epochs=1001)

pred = model.predict(test_x)
pred = tf.where(pred>=0.5,tf.ones_like(pred),tf.zeros_like(pred))

print(accuracy_score(test_y,pred))
print(confusion_matrix(test_y,pred))
print(classification_report(test_y,pred))
